USE [SIVN_Security]
GO
/****** Object:  ForeignKey [FK_Friend_User]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[Friend] DROP CONSTRAINT [FK_Friend_User]
GO
/****** Object:  ForeignKey [FK_Group_User]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[Group] DROP CONSTRAINT [FK_Group_User]
GO
/****** Object:  ForeignKey [FK_GroupMember_Group]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[GroupMember] DROP CONSTRAINT [FK_GroupMember_Group]
GO
/****** Object:  ForeignKey [FK_GroupMember_User]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[GroupMember] DROP CONSTRAINT [FK_GroupMember_User]
GO
/****** Object:  Table [security].[GroupMember]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[GroupMember] DROP CONSTRAINT [FK_GroupMember_Group]
GO
ALTER TABLE [security].[GroupMember] DROP CONSTRAINT [FK_GroupMember_User]
GO
DROP TABLE [security].[GroupMember]
GO
/****** Object:  Table [security].[Friend]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[Friend] DROP CONSTRAINT [FK_Friend_User]
GO
DROP TABLE [security].[Friend]
GO
/****** Object:  Table [security].[Group]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[Group] DROP CONSTRAINT [FK_Group_User]
GO
DROP TABLE [security].[Group]
GO
/****** Object:  Table [security].[User]    Script Date: 06/11/2012 16:10:45 ******/
DROP TABLE [security].[User]
GO
/****** Object:  Schema [security]    Script Date: 06/11/2012 16:10:44 ******/
DROP SCHEMA [security]
GO
/****** Object:  Schema [security]    Script Date: 06/11/2012 16:10:44 ******/
CREATE SCHEMA [security] AUTHORIZATION [dbo]
GO
/****** Object:  Table [security].[User]    Script Date: 06/11/2012 16:10:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [security].[User](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](100) NOT NULL,
	[Password] [nvarchar](100) NOT NULL,
	[CreatedDate] [datetime] NOT NULL,
	[CreatedBy] [nvarchar](100) NOT NULL,
	[ModifiedDate] [datetime] NOT NULL,
	[ModifiedBy] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [security].[Group]    Script Date: 06/11/2012 16:10:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [security].[Group](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](200) NOT NULL,
	[GoupOwner] [int] NOT NULL,
	[CreatedDate] [datetime] NOT NULL,
	[CreatedBy] [nvarchar](100) NOT NULL,
	[ModifiedDate] [datetime] NOT NULL,
	[ModifiedBy] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_Group] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [security].[Friend]    Script Date: 06/11/2012 16:10:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [security].[Friend](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[User_Id] [int] NOT NULL,
	[Friend_Id] [int] NOT NULL,
	[Status] [nvarchar](100) NOT NULL,
	[CreatedDate] [datetime] NOT NULL,
	[CreatedBy] [nvarchar](100) NOT NULL,
	[ModifiedDate] [datetime] NOT NULL,
	[ModifiedBy] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_Friend] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [security].[GroupMember]    Script Date: 06/11/2012 16:10:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [security].[GroupMember](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[GroupId] [int] NOT NULL,
	[UserId] [int] NOT NULL,
	[CreatedDate] [datetime] NOT NULL,
	[CreatedBy] [nvarchar](100) NOT NULL,
	[ModifiedDate] [datetime] NOT NULL,
	[ModifiedBy] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_GroupMember] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_Friend_User]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[Friend]  WITH CHECK ADD  CONSTRAINT [FK_Friend_User] FOREIGN KEY([User_Id])
REFERENCES [security].[User] ([Id])
GO
ALTER TABLE [security].[Friend] CHECK CONSTRAINT [FK_Friend_User]
GO
/****** Object:  ForeignKey [FK_Group_User]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[Group]  WITH CHECK ADD  CONSTRAINT [FK_Group_User] FOREIGN KEY([GoupOwner])
REFERENCES [security].[User] ([Id])
GO
ALTER TABLE [security].[Group] CHECK CONSTRAINT [FK_Group_User]
GO
/****** Object:  ForeignKey [FK_GroupMember_Group]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[GroupMember]  WITH CHECK ADD  CONSTRAINT [FK_GroupMember_Group] FOREIGN KEY([GroupId])
REFERENCES [security].[Group] ([Id])
GO
ALTER TABLE [security].[GroupMember] CHECK CONSTRAINT [FK_GroupMember_Group]
GO
/****** Object:  ForeignKey [FK_GroupMember_User]    Script Date: 06/11/2012 16:10:45 ******/
ALTER TABLE [security].[GroupMember]  WITH CHECK ADD  CONSTRAINT [FK_GroupMember_User] FOREIGN KEY([UserId])
REFERENCES [security].[User] ([Id])
GO
ALTER TABLE [security].[GroupMember] CHECK CONSTRAINT [FK_GroupMember_User]
GO
